package com.blue.integration.pay.swift;

import com.blue.integration.pay.PayState;

/**
 * 威富通XML响应参数
 *
 * @author zhengjin
 * @since 1.0 2017年12月14日
 */
public class XmlSwiftPayResponse
{
	private String appid; //公众账号 ID
	private String charset; //编码
	private String mchId; //商户号
	private String nonceStr; //随机字符串
	private String resultCode; // 0 标识交易成功  非0标识交易失败
	private String sign; //签名
	private String signType;  //签名方式
	private String status;  //0 表示成功  非0 表示失败  此状态只标识通信成功，而非交易状态
	private String version; //版本号
	private String errCode; //错误代码
	private String errMsg; //错误代码描述
	private String message; // 返回信息，如非空，为错误原因签名失败参数格式校验错误
	private String outTradeNo; // 订单号
	private String transactionId; // 威富通订单号
	private String tradeState; // 支付状态
	private String tokenId; //动态口令
	private String payInfo; // 原生支付json参数
	private String codeUrl; // 支付链接
	private String codeImgUrl; // 支付二维码图片链接

	public XmlSwiftPayResponse()
	{
	}

	public SwiftPayResponse toResponse()
	{
		SwiftPayResponse response = new SwiftPayResponse();
		if ("0".equals(status))
		{
			if ("0".equals(resultCode))
			{
				response.setSuccess(true);
			}
			else
			{
				response.setSuccess(false);
			}
			response.setCode(errCode);
			response.setMessage(errMsg);
		}
		else
		{
			response.setSuccess(false);
			response.setCode(status);
			response.setMessage(message);
		}
		response.setAppid(appid);
		response.setMchId(mchId);
		response.setTokenId(tokenId);
		response.setPayInfo(payInfo);
		response.setCodeUrl(codeUrl);
		response.setCodeImgUrl(codeImgUrl);

		PayState state = PayState.getState(tradeState);
		if (state == null)
			state = PayState.NOPAY;
		response.setState(state);

		return response;
	}

	public String getAppid()
	{
		return appid;
	}

	public void setAppid(String appid)
	{
		this.appid = appid;
	}

	public String getCharset()
	{
		return charset;
	}

	public void setCharset(String charset)
	{
		this.charset = charset;
	}

	public String getMchId()
	{
		return mchId;
	}

	public void setMchId(String mchId)
	{
		this.mchId = mchId;
	}

	public String getNonceStr()
	{
		return nonceStr;
	}

	public void setNonceStr(String nonceStr)
	{
		this.nonceStr = nonceStr;
	}

	public String getResultCode()
	{
		return resultCode;
	}

	public void setResultCode(String resultCode)
	{
		this.resultCode = resultCode;
	}

	public String getSign()
	{
		return sign;
	}

	public void setSign(String sign)
	{
		this.sign = sign;
	}

	public String getSignType()
	{
		return signType;
	}

	public void setSignType(String signType)
	{
		this.signType = signType;
	}

	public String getStatus()
	{
		return status;
	}

	public void setStatus(String status)
	{
		this.status = status;
	}

	public String getTokenId()
	{
		return tokenId;
	}

	public void setTokenId(String tokenId)
	{
		this.tokenId = tokenId;
	}

	public String getPayInfo()
	{
		return payInfo;
	}

	public void setPayInfo(String payInfo)
	{
		this.payInfo = payInfo;
	}

	public String getVersion()
	{
		return version;
	}

	public void setVersion(String version)
	{
		this.version = version;
	}

	public String getErrCode()
	{
		return errCode;
	}

	public void setErrCode(String errCode)
	{
		this.errCode = errCode;
	}

	public String getErrMsg()
	{
		return errMsg;
	}

	public void setErrMsg(String errMsg)
	{
		this.errMsg = errMsg;
	}

	public String getMessage()
	{
		return message;
	}

	public void setMessage(String message)
	{
		this.message = message;
	}

	public String getOutTradeNo()
	{
		return outTradeNo;
	}

	public void setOutTradeNo(String outTradeNo)
	{
		this.outTradeNo = outTradeNo;
	}

	public String getTransactionId()
	{
		return transactionId;
	}

	public void setTransactionId(String transactionId)
	{
		this.transactionId = transactionId;
	}

	public String getTradeState()
	{
		return tradeState;
	}

	public void setTradeState(String tradeState)
	{
		this.tradeState = tradeState;
	}

	public String getCodeUrl()
	{
		return codeUrl;
	}

	public void setCodeUrl(String codeUrl)
	{
		this.codeUrl = codeUrl;
	}

	public String getCodeImgUrl()
	{
		return codeImgUrl;
	}

	public void setCodeImgUrl(String codeImgUrl)
	{
		this.codeImgUrl = codeImgUrl;
	}
}
